
const app = getApp()
var t = getApp(), a = t.requirejs("core"), e = t.requirejs("wxParse/wxParse"), i = t.requirejs("biz/diypage"), s = t.requirejs("biz/diyform"), n = t.requirejs("biz/goodspicker"), o = (t.requirejs("foxui"), 
t.requirejs("jquery"));
Page({
  data: {
    article:'',
    isClick:true,
    orginelist:[],//原图
    limitImg:9,
    bid:'',
    pid:'',
    rpid:'',
  },
  itemDel(e){
    let orginelist=this.data.orginelist;
    orginelist.splice(e.currentTarget.dataset.index,1);
    this.setData({
      orginelist:orginelist
    })
  },
  addPic(){
    let that=this;
    let orginelist=this.data.orginelist;
    a.upload(function(e) {
      orginelist.push(e.url)
      that.setData({
        orginelist:orginelist
      })
    })
  },
  articleC(e){
    this.setData({
      article:e.detail.value
    })
  },
  //保存
  send(){
    if(!this.data.isClick)return
    this.setData({
      isClick:false
    });
    
    let t=setTimeout(()=>{
      clearTimeout(t)
      this.setData({
        isClick:true
      });
    },5000);
    let that=this;
    a.post("sns/board/reply", {
      bid:that.data.bid,
      pid:that.data.pid,
      rpid:that.data.rpid,
      content:that.data.article,
      images:that.data.orginelist,
    }, function(res) {
      if(res.error==-2){
        wx.showToast({
          title:res.message,
          icon:'none'
        })
        return
      }
      wx.navigateBack();
    });
  },
  onLoad: function (options) {
    let that=this;
    wx.getSystemInfo({
      success: (result) => {
        that.setData({
          windowWidth:result.windowWidth
        })
      },
    })
   if(options.bid){
      this.setData({
        bid:options.bid,
      })
   }
   if(options.pid){
    this.setData({
      pid:options.pid,
    })
   }
    if(options.rpid){
      this.setData({
        rpid:options.rpid,
      })
      wx.setNavigationBarTitle({
        title: '回复评论',
      })
    }
  },
  onReady: function () {
    
  },
  onShow: function () {
  },
  onHide: function () {

  },
  onUnload: function () {

  },
  onPullDownRefresh: function () {

  },
  onReachBottom: function () {

  }
})